const fs = window.require("fs");
const path = window.require("path");

// import { readdirSync, statSync } from "fs";
// import { join, extname } from "path";

export function getAllFilePath(filePath: string, outPaths: string[],suffix:string) {
    try {
        let stat = fs.statSync(filePath)
        if (stat.isDirectory()) {
            let files:string[] = fs.readdirSync(filePath);
            files.forEach(f => {
                let ifurl = path.join(filePath, f)
                getAllFilePath(ifurl, outPaths,suffix);
            })
        } else if (stat.isFile()) {
            // let ext = extname(path);
            // if (ext == '.jpg' || ext == '.png' || ext == '.jpeg') {
            //     outPaths.push(path);
            // }
            if(filePath.endsWith(suffix)){
                outPaths.push(filePath)
            }
        }
    } catch (e) {
        throw e;
        
        console.log(e)
    }
}

